package com.jprocms.module.cms.controller.portal.page;

import com.jprocms.module.cms.dal.dataobject.site.SiteDO;
import com.jprocms.module.cms.service.site.SiteService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;


/**
 * 前台首页 Controller
 *
 * @author jprocms
 */
@Controller
public class IndexPageController {
    private final SiteService siteService;

    public IndexPageController(SiteService siteService) {
        this.siteService = siteService;
    }

    @GetMapping({"/", "/{sitePath:[\\w-]+}"})
    public String index(@PathVariable(required = false) String sitePath, Map<String, Object> model) {
        SiteDO site = siteService.getSite(sitePath);
        model.put("isIndex", true);
        return site.getTpl();
    }


}
